package com.ruoyi.InboundManagement.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.InboundManagement.domain.ReceivingInbound;
import com.ruoyi.InboundManagement.service.IReceivingInboundService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 收货入库管理Controller
 * 
 * @author admin
 * @date 2024-07-03
 */
@RestController
@RequestMapping("/InboundManagement/receivingInbound")
public class ReceivingInboundController extends BaseController
{
    @Autowired
    private IReceivingInboundService receivingInboundService;

    /**
     * 查询收货入库管理列表
     */
    @PreAuthorize("@ss.hasPermi('InboundManagement:receivingInbound:list')")
    @GetMapping("/list")
    public TableDataInfo list(ReceivingInbound receivingInbound)
    {
        startPage();
        List<ReceivingInbound> list = receivingInboundService.selectReceivingInboundList(receivingInbound);
        return getDataTable(list);
    }

    /**
     * 导出收货入库管理列表
     */
    @PreAuthorize("@ss.hasPermi('InboundManagement:receivingInbound:export')")
    @Log(title = "收货入库管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ReceivingInbound receivingInbound)
    {
        List<ReceivingInbound> list = receivingInboundService.selectReceivingInboundList(receivingInbound);
        ExcelUtil<ReceivingInbound> util = new ExcelUtil<ReceivingInbound>(ReceivingInbound.class);
        util.exportExcel(response, list, "收货入库管理数据");
    }

    /**
     * 获取收货入库管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('InboundManagement:receivingInbound:query')")
    @GetMapping(value = "/{receivingId}")
    public AjaxResult getInfo(@PathVariable("receivingId") Long receivingId)
    {
        return success(receivingInboundService.selectReceivingInboundByReceivingId(receivingId));
    }

    /**
     * 新增收货入库管理
     */
    @PreAuthorize("@ss.hasPermi('InboundManagement:receivingInbound:add')")
    @Log(title = "收货入库管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ReceivingInbound receivingInbound)
    {
        return toAjax(receivingInboundService.insertReceivingInbound(receivingInbound));
    }

    /**
     * 修改收货入库管理
     */
    @PreAuthorize("@ss.hasPermi('InboundManagement:receivingInbound:edit')")
    @Log(title = "收货入库管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ReceivingInbound receivingInbound)
    {
        return toAjax(receivingInboundService.updateReceivingInbound(receivingInbound));
    }

    /**
     * 删除收货入库管理
     */
    @PreAuthorize("@ss.hasPermi('InboundManagement:receivingInbound:remove')")
    @Log(title = "收货入库管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{receivingIds}")
    public AjaxResult remove(@PathVariable Long[] receivingIds)
    {
        return toAjax(receivingInboundService.deleteReceivingInboundByReceivingIds(receivingIds));
    }
}
